<?php
class TbfEncoding{
    static function AjkError($str){
        echo json_encode(array('err'=>$str));
        return null;
    }
    static function AjkSuccess($data=null){
        echo json_encode(array('err'=>'','data'=>$data));
        return null;
    }
    static function JsonEncode($data){
        return json_encode($data);
    }
    static function JsonDecode($str){
        return json_decode($str,true);
    }
    static function base64UrlEncode($s){
        $s = base64_encode($s);
        $s = strtr($s,array('+'=>'-','/'=>'_'));
        return rtrim($s,'=');

    }
    static function base64UrlDecode($s){
        $s = strtr($s,array('-'=>'+','_'=>'/'));
        $s = str_pad($s,strlen($s)%4,'=',STR_PAD_RIGHT);
        return base64_decode($s,true);
    }
}
